﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Informator.Presentation.Nastava_i_vezbe
{
    public class PredmetModel
    {
        private Predmet _view;
        public string SalaNaziv { get; set; }
        public string SalaTip { get; set; }
        public string ImePredmeta { get; set; }
        public TimeSpan PocetakPredavanja { get; set; }
        public TimeSpan KrajPredavanja { get; set; }
        public double MaxWidth { get; set; }
        public TimeSpan TrajanjePredmeta { 
            get { return KrajPredavanja - PocetakPredavanja; }
        }
        public DayOfWeek Dan { get; set; }
        public Predmet View
        {
            get
            {
                if (_view == null)
                    _view = new Predmet(this);
                return _view;
            }
            private set { }
        }

        public double PreostaloVremena{
            get { return (KrajPredavanja - DateTime.Now.TimeOfDay).TotalSeconds; }
        }
        public double ProsloVreme
        {
            get { return TrajanjePredmeta.TotalSeconds - PreostaloVremena; }
        }

        public bool CheckValidity()
        {
            var flag = PocetakPredavanja.CompareTo(DateTime.Now) < 0
                      && KrajPredavanja.CompareTo(DateTime.Now) > 0;
            return flag;
        }
    }
}
